(* =============================================== *)
(* lexer pour l'analyse lexicale du code net_list  *)
(* author Mathieu Barbin, Ocan Sankur              *)
(* version samedi 17 novembre 2007                 *)
(* =============================================== *)

{ 
  open ParserNet
  open Inputtools
}

rule lexem_list = parse
  | (['/'] ['*'] ([^'*'] | (['*'] [^'/']))* 
       ['*'] ['/']) as code                      { ignore (string_filtree (fun _ -> false) Net_list code); 
						   lexem_list lexbuf }  
  | (['/'] ['/'] [^'\n']* ['\n'])                { incr(index_ligne_net_list); 
						   lexem_list lexbuf }
  | ['\n']                                       { incr(index_ligne_net_list);
						   lexem_list lexbuf }
  | [' ' '\t'] +                                 { lexem_list lexbuf }
  | "#setCPS"                                    { SETCPS }
  | "#define"                                    { DEFINE }
  | "#include"                                   { TAG_INCLUDE }
  | "external"                                   { EXTERNAL }
  | "init"                                       { INIT }
  | "def"                                        { DEF }
  | "with"                                       { WITH }
  | "unused"                                     { UNUSED }
  | "where"                                      { WHERE }
  | "end"                                        { END }
  | "pipe"                                       { TOK_PIPE }
  | "ROM"                                        { ROM }
  | "RAM"                                        { RAM }
  | "text"                                       { TEXT }
  | "file"                                       { FILE }
  | "binaryfile"                                 { BINARYFILE }
  | "for"                                        { FOR }
  | "do"                                         { DO }
  | "to"                                         { TO }
  | "if"                                         { IF }
  | "then"                                       { THEN }
  | "else"                                       { ELSE }
  | "log"                                        { LEX_LOG }
  | "mod"                                        { LEX_MOD }
  | "min"                                        { LEX_MIN }
  | "max"                                        { LEX_MAX }
  | "&&"                                         { LEX_AND }
  | "||"                                         { LEX_OR }
  | "|"                                          { LEX_OR }
  | "&"                                          { LEX_AND }
  | (['{'] [^'{']* ['}']) as code                { CODE (reduction01 Net_list code) } 
  | (['0'-'9']+) as entier                       { INT (int_of_string entier) }
  | "+"                                          { LEX_ADD }
  | "-"                                          { LEX_SUB }
  | "/"                                          { LEX_DIV }
  | "^"                                          { LEX_EXP }
  | "**"                                         { LEX_EXP }
  | "*"                                          { LEX_MULT }
  | "("                                          { LPAREN } 
  | ")"                                          { RPAREN }
  | "=="                                         { CONDEGAL }
  | "!="                                         { NOTEGAL }
  | "!"                                          { POINT_EXCLAM }
  | "<>"                                         { NOTEGAL }
  | "<="                                         { PPETIT }
  | ">="                                         { PGRAND }
  | "="                                          { EGAL }
  | "<"                                          { SPPETIT }
  | ">"                                          { SPGRAND }
  | ";"                                          { POINT_VIRG }
  | "?"                                          { POINT_INTER }
  | "$"                                          { DOLLAR }
  | ".."                                         { POINTPOINT }
  | ","                                          { VIRG }
  | ":"                                          { DEUX_POINTS }
  | "."                                          { POINT }
  | "{"                                          { LACC }
  | "}"                                          { RACC }
  | "["                                          { LCROCHET }
  | "]"                                          { RCROCHET }
  | (['A'-'Z' 'a'-'z' '_' '\'' '~'] 
       ['A'-'Z' 'a'-'z' '0'-'9' '_' '\'' '~']*)
      as name                                    { IDENT name }
  | (['\"'] [^'\"']* ['\"']) as chaine           { STRING (reductionName Net_list chaine) } 
  
(* | (['<'] ['a'-'z' '_'] 
      ['A'-'Z' 'a'-'z' '_' '0'-'9' '.']* ['>']) 
      as include_name                            { TAG_FILE_INCLUDE (reductionInclude Net_list include_name) }
*)

  | eof                                          { EOF }
      
